<?php
class M_DbTable_Cruise extends Apps_Db_Table_Abstract {
	protected $_name = 'cruise';

	const STATUS_ACTIVE  	= 1;
	const STATUS_INACTIVE  	= 0;
	const STATUS_DELETED  	= -1;

	const SPECIAL_OFFER_TRUE 	= 1;
	const SPECIAL_OFFER_FALSE 	= 0;
	
	const BEST_SELLING_TRUE 	= 1;
	const BEST_SELLING_FALSE 	= 0;

	public function getList() {
		$q = $this->_db
				  ->select()
				  ->from(array('c'   => $this->_name), null)
				  ->join(array('c_c' => 'cruise_category'), 'c_c.id = c.cruise_category_id', null)
				  ->join(array('c_t' => 'cruise_type'), 'c_t.id = c.cruise_type_id', null)
				  ->where('c.status !=?', self::STATUS_DELETED)
				  ->order('c.en_name')
				  ->columns(
				  		array('id'						=>  'c.id',
							  'name'					=>	'c.name',
							  'en_name'					=>	'c.en_name',
				  		      'status'                  =>  'c.status',
							  'cruise_category_id'	    =>	'c_c.id',
							  'cruise_category_title'	=>	'c_c.en_title',
							  'cruise_type_id'		    =>	'c_t.id',
							  'cruise_type_title'		=>	'c_t.en_title',
							  'description'				=>	'c.description'
				  ));
		return $q;
	}

	public function getCruise($id) {
		$q = $this->_db
				  ->select()
				  ->from(array('c'   => $this->_name), null)
				  ->join(array('c_c' => 'cruise_category'), 'c_c.id = c.cruise_category_id', null)
				  ->join(array('c_t' => 'cruise_type'), 'c_t.id = c.cruise_type_id', null)
				  ->where('c.id =?', $id)
				  ->columns(
				  		array('id'						=>  'c.id',
							  'name'					=>	'c.name',
							  'en_name'					=>	'c.en_name',
							  'country_id'				=>	'c.country_id',
							  'description'				=>	'c.description',
				  				
							  'cruise_category_id'	    =>	'c_c.id',
							  'cruise_type_id'		    =>	'c_t.id',
				  ));
		return $q;
	}
}